/**
 * Created by hdax on 2017/12/12.
 */
// $(document).ready(function () {
//     $("div.div_5").mouseover(function () {
//         $(this).css("background-color","#f01e28");
//     });
//     $("div.div_5").mouseout(function () {
//         $(this).css("background-color","#ffffff");
//     });
// });
    //定义一个二维数组，存储省、市信息
     var provList=['河北省(城市列表)','河南省(城市列表)','山东省(城市列表)','山西省(城市列表)'];
     provList[0]=['石家庄市','邯郸市','邢台市','保定市'];
     provList[1]=['郑州市','安阳市','洛阳市','商丘市'];
     provList[2]=['青岛市','济南市','日照市','淄博市'];
     provList[3]=['太原市','大同市','吕梁市','晋城市'];
     $(function () {
         $('#province').change(function () {
             $('#city').empty();
             var prov =$(this).val();
             if (prov!=-1){
                 var cityList =provList[prov];
                 console.log(cityList);
                 $.each(cityList,function (i,e) {
                     var opt = $('<option value="' + i + '">' + e + '</option>');
                     $('#city').append(opt);
                 })
             }else {
                 $('#city').append('<option value="-1">请选择</option>');
             }
         })
     })

// 区
$(function () {
    $('div.div_5').click(function () {
    $('.ha').show();
    $('.bai').show();
})
$('.div_one>img').click(function () {
    $('.ha').hide();
    $('.bai').hide();
})
})

$(function () {
    $('.div_20>button').click(function () {
        var b =$('#xm').val();
        var a =$('#sjh').val();

        var c =$('.shengfeng :selected').text();
        var d =$('.city #city :selected').text();
        var xian = $('#xian :selected').text();
        var jia = $("#mo:checked").val();
        if(b!=''){
            if(a!=''){
                var sjh = /^1\d{10}$/
                if(sjh.test(a)){
                	if(jia!=null){
                		//异步
                        $(document).load("addressmo.do",{"name":b,"phone":a,"sheng":c,"shi":d,"xian":xian,"addressxiang":e},function(){
                        	
                        })
                        var e =$('#jiedao>input').val();
                        var diaoyong ="<li>"
                            +"<div class='div_xing'>"
                            +"<p>"+b+"</p>"
                            +"<p>"+a+"</p>"
                            +"<p>"+c+"&nbsp;"+d+"&nbsp;"+xian+"</p>"
                            +"<p>"+e+"</p>"
                            +"</div>"
                            +"</li>"
                        $('.div_4>ul').prepend(diaoyong);
                        $('.ha').hide();
                        $('.bai').hide();
                	}else{
                		//异步
                        $(document).load("address.do",{"name":b,"phone":a,"sheng":c,"shi":d,"xian":xian,"addressxiang":e},function(){
                        	
                        })
                		
                		var e =$('#jiedao>input').val();
                        var diaoyong ="<li>"
                            +"<div class='div_xingl'>"
                            +"<p>"+b+"</p>"
                            +"<p>"+a+"</p>"
                            +"<p>"+c+"&nbsp;"+d+"&nbsp;"+xian+"</p>"
                            +"<p>"+e+"</p>"
                            +"</div>"
                            +"</li>"
                        $('.div_4>ul').prepend(diaoyong);
                        
                        
                        $('.ha').hide();
                        $('.bai').hide();
                	}
                	
                    
                }else{
                    $('#sjh').val('手机号格式不正确')
                }
            }else{
                $('#sjh').attr('placeholder','手机号不能为空')
            }
        }else{
            $('#xm').attr('placeholder','姓名不能为空')
        }

    })
    $(".div_4>ul>li>div").click(function(){
    	$(".div_4>ul>li").siblings().children().attr("class","div_xingl");
    	$(this).attr("class","div_xing");
    	var jia = $(this).children("input").val();
    	$(document).load("addressxiu.do",{"mo":jia},function(){
    		
    	})
    	$("#div_5").attr("class","div_5");
    })
})

$(function () {
    $('#sjh').blur(function () {
        var sjh = /^15[ 1 3 7]\d{8}$/
        var s = $('#sjh').val();
        if (sjh.test(s)) {
            $('#sjh').parent().children('.tu').children('img').attr("src", 'images/dui.png');
            $('#sjh').parent().children('.tu').css('display', 'block')
        } else {
            $('#sjh').parent().children('.tu').children('img').attr("src", 'images/chuo.png');
            $('#sjh').parent().children('.tu').css('display', 'block')
        }
    })
})
// 手机号验证
function mima() {
    $('#mima').blur(function () {
        var mima = /^[0-9 a-z A-Z .]{6,16}$/
        var s = $('#mima').val();
        if(mima.test(s)){
            $('#mima').parent().parent().children('.tu').children('img').attr("src",'images/dui.png');
            $('#mima').parent().parent().children('.tu').css('display','block')
        }else{
            $('#mima').parent().parent().children('.tu').children('img').attr("src",'images/chuo.png');
            $('#mima').parent().parent().children('.tu').css('display','block')
        }
    })

}

